package pl.mchaniewski.ryneczek.pojo;

// Generated Oct 3, 2011 3:17:38 AM by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import pl.mchaniewski.ryneczek.utilities.DateUtil;

@Entity
@Table(name = "quotation", catalog = "stockmarket")
public class Quotation implements java.io.Serializable {
    private static final long serialVersionUID = -2013670954089629063L;

    private Integer quotationid;
    private Company company;
    private BigDecimal openValue;
    private BigDecimal minimumValue;
    private BigDecimal maximumValue;
    private BigDecimal currentValue;
    private Float dailyChange;
    private Integer tradingVolume;
    private Integer marketValue;
    private Date listingDate;

    public Quotation() {
    }

    public Quotation(Company company, BigDecimal openValue,
            BigDecimal minimumValue, BigDecimal maximumValue,
            BigDecimal currentValue, Date listingDate) {
        this.company = company;
        this.openValue = openValue;
        this.minimumValue = minimumValue;
        this.maximumValue = maximumValue;
        this.currentValue = currentValue;
        this.listingDate = listingDate;
    }

    public Quotation(Company company, BigDecimal openValue,
            BigDecimal minimumValue, BigDecimal maximumValue,
            BigDecimal currentValue, Float dailyChange, Integer tradingVolume,
            Integer marketValue, Date listingDate) {
        this.company = company;
        this.openValue = openValue;
        this.minimumValue = minimumValue;
        this.maximumValue = maximumValue;
        this.currentValue = currentValue;
        this.dailyChange = dailyChange;
        this.tradingVolume = tradingVolume;
        this.marketValue = marketValue;
        this.listingDate = listingDate;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "QUOTATIONID", unique = true, nullable = false)
    public Integer getQuotationid() {
        return quotationid;
    }

    public void setQuotationid(Integer quotationid) {
        this.quotationid = quotationid;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "COMPANYID", nullable = false)
    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    @Column(name = "OPEN_VALUE", nullable = false)
    public BigDecimal getOpenValue() {
        return openValue;
    }

    public void setOpenValue(BigDecimal openValue) {
        this.openValue = openValue;
    }

    @Column(name = "MINIMUM_VALUE", nullable = false)
    public BigDecimal getMinimumValue() {
        return minimumValue;
    }

    public void setMinimumValue(BigDecimal minimumValue) {
        this.minimumValue = minimumValue;
    }

    @Column(name = "MAXIMUM_VALUE", nullable = false)
    public BigDecimal getMaximumValue() {
        return maximumValue;
    }

    public void setMaximumValue(BigDecimal maximumValue) {
        this.maximumValue = maximumValue;
    }

    @Column(name = "CURRENT_VALUE", nullable = false)
    public BigDecimal getCurrentValue() {
        return currentValue;
    }

    public void setCurrentValue(BigDecimal currentValue) {
        this.currentValue = currentValue;
    }

    @Column(name = "DAILY_CHANGE", precision = 12, scale = 0)
    public Float getDailyChange() {
        return dailyChange;
    }

    public void setDailyChange(Float dailyChange) {
        this.dailyChange = dailyChange;
    }

    @Column(name = "TRADING_VOLUME")
    public Integer getTradingVolume() {
        return tradingVolume;
    }

    public void setTradingVolume(Integer tradingVolume) {
        this.tradingVolume = tradingVolume;
    }

    @Column(name = "MARKET_VALUE")
    public Integer getMarketValue() {
        return marketValue;
    }

    public void setMarketValue(Integer marketValue) {
        this.marketValue = marketValue;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "LISTING_DATE", nullable = false, length = 19)
    public Date getListingDate() {
        return listingDate;
    }

    public void setListingDate(Date listingDate) {
        this.listingDate = listingDate;
    }

    @Transient
    public String getFormattedTime() {
        return DateUtil.timeToString(listingDate);
    }

    @Transient
    public String getFormattedDate() {
        return DateUtil.simpleDateToString(listingDate);
    }

}
